
project(myctkdemo)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)

include_directories(
    # ${Qt5Widgets_INCLUDE_DIRS}
    # ${Qt5Core_INCLUDE_DIRS}
    # ${Qt5Gui_INCLUDE_DIRS}
    # ${Boost_INCLUDE_DIRS}
    # ${CMAKE_SOURCE_DIR}/src/
    ${OCC_INCLUDE_DIR}
    ${CTK_INCLUDE_DIRS}

) 
file(GLOB_RECURSE  BASE_FILE 
#"${CMAKE_SOURCE_DIR}/src/Base/Common/*.cpp"
"${CMAKE_SOURCE_DIR}/src/Base/Common/*.h"
)

message("BASE_FILE:" ${BASE_FILE})
# 获取所有的 .cpp 文件
file(GLOB_RECURSE  SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")


# 获取所有的 .h 文件
file(GLOB_RECURSE  HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/*.h")

# 获取所有的资源文件
file(GLOB_RECURSE  RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.qrc")
# 获取所有的 UI 文件
file(GLOB_RECURSE  UI_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.ui")

QT5_WRAP_CPP(MOC_FILES ${HEADERS})

set(MAIN_SRC 
     ${SOURCES}
    ${HEADERS}
    ${RESOURCES}
    ${UI_FILES}
    ${MOC_FILES}
)

message("Build File List:")
foreach(src ${MAIN_SRC})
    message("  ${src}---------")
endforeach()


link_directories(
if(CMAKE_BUILD_TYPE MATCHES Debug)
    ${CMAKE_SOURCE_DIR}/lib/Debug/
else()
   ${CMAKE_SOURCE_DIR}/lib/Release/
endif()
)
message("CTK_LIBRARY_DIRS:--------------------------------" ${CTK_LIBRARY_DIRS})
SET(Main_LIBS
    ${Qt5Core_LIBRARIES}
    ${Qt5Gui_LIBRARIES}  
    ${Qt5Widgets_LIBRARIES}
    #CTKCore
    CTKPluginFramework
    #BasePluginModel
    #BaseViewModel
    base
)


# set(Main_SRCS
#     ${CMAKE_CURRENT_BINARY_DIR}/GoBot.rc
#     icon.ico
#     MainGui.cpp
# )


add_executable(${PROJECT_NAME} ${MAIN_SRC})


target_link_libraries(${PROJECT_NAME} 
${Main_LIBS}
)

get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
find_program(DEPLOYQT_EXECUTABLE NAMES windeployqt HINTS "${_qt_bin_dir}")

add_custom_command(TARGET ${PROJECT_NAME}
    POST_BUILD
    COMMAND ${DEPLOYQT_EXECUTABLE} "$<TARGET_FILE:${PROJECT_NAME}>"
        $<$<CONFIG:Debug>:--debug> --qmldir ${CMAKE_SOURCE_DIR}
)

# add_custom_command(TARGET ${PROJECT_NAME}
#         POST_BUILD
#        COMMAND ${CMAKE_COMMAND} -E copy_if_different 
#                        ${QM_FILES}
#                        ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/translations
#         DEPENDS ${QM_FILES}
#         BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/lang/*.qm 
# )